<?php
namespace Api\Controller;
use Think\Controller;
class TrainController extends Controller {
    public function getTrain(){

        // $m_id = $_GET['m_id'];

        $train = M('train');
        $data = $train -> order("train_id")->select();

        echo json_encode($data);
         echo "<br>";

    }
  public function Traindetail(){
      $train_id=$_GET['train_id'];
      $trainmodel=M('train');
      $train=$trainmodel->find($train_id); 
      $this->train=$train;
      exit(json_encode($train));
    } 


public function addTrain(){
        //调用模型层获取数据

    $data['train_id']=$_GET['train_id'];
    $data['club_id']=$_GET['club_id'];
    $data['train_name']=$_GET['train_name'];
    $data['train_pic']=$_GET['train_pic'];
    $data['train_intro']=$_GET['train_intro'];
    $data['train_price']=$_GET['train_price'];
    $data['train_teacher']=$_GET['train_teacher'];
    $data['train_phone']=$_GET['train_phone'];
      $data['train_time'] =  date("Y-m-d H:i:s"); 
      
    $trainmodel=M('train');
    
    
  
                                              
    $train=$trainmodel->add($data);

    if(false !==$train){
         
        
    $this->ajaxReturn(SUCCESS,'JSON');

    }else{
        //$this->false;
         $this->ajaxReturn($FALSE,'JSON');

    }
              
 

    }
}
?>